@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        管理员权限
        <small>修改</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li><a href="#"><i class="fa fa-dashboard"></i> 管理员设置</a></li>
        <li class="active">管理员权限</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">管理员权限修改</h3>
                    <div class="box-tools">
                        <a href="{{Route('admin.admin_action.index')}}" type="button" class="btn btn-block btn-success btn-xs"><i class="icon  glyphicon glyphicon glyphicon-menu-left"></i> 返回</a>
                    </div>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                {!! Form::model($adminAction,['route'=>['admin.admin_action.update',$adminAction->id],'method'=>'put'])  !!}
                    {!! Form::hidden('back_url',@$_SERVER['HTTP_REFERER']) !!}
                    <div class="box-body">
                        <?php $select = $adminAction::getTreeList();?>

                        <?php

                        function myspace($n,$hasChild){
                            $enum = ['├','└'];
                            if ($hasChild){
                                $space = $enum[0];
                            }else{
                                $space = $enum[1];
                            }
                            $str = '';
                            for ($i=0;$i<=$n;$i++){
                                $str.='&nbsp;&nbsp;';
                            }
                            return $str.$space;
                        }
                        $seletcItem[0] = '=请选择父节点=';

                        foreach ($select as $k=> $item){
                            $seletcItem [$item->id]= myspace($item->deepth,$item->has_children).$item->name;
                        }

                        ?>
                        <div class="form-group @if($errors->has('parent_id')) has-error   @endif">
                            <label for="exampleInputPassword1">父级节点</label>
                            {!! Form::select('parent_id',$seletcItem,old('parent_id'),['class'=>'form-control','disabled'=>'disabled'])!!}
                            @if($errors->has('parent_id'))
                                <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('parent_id')}}</label>
                            @endif
                        </div>
                        <div class="form-group @if($errors->has('name')) has-error   @endif">
                            <label for="exampleInputEmail1">权限名称</label>
                            {!! Form::text('name',old('name'),array('class'=>'form-control','placeholder'=>'请填写权限名称,如:商品管理'))!!}
                            @if($errors->has('name'))
                                <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('name')}}</label>
                            @endif
                        </div>
                        <div class="form-group @if($errors->has('url')) has-error   @endif">
                            <label for="exampleInputEmail1">URL</label>
                            {!! Form::text('url',old('url'),array('class'=>'form-control','placeholder'=>'请填写URL,如:/admin/admin_user'))!!}
                            @if($errors->has('url'))
                                <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('url')}}</label>
                            @endif
                        </div>

                        <div class="form-group @if($errors->has('action')) has-error   @endif">
                            <label for="exampleInputEmail1">请求动作</label>
                            {!! Form::text('action',old('action'),array('class'=>'form-control','placeholder'=>'请填写动作,如:destroy'))!!}
                            @if($errors->has('action'))
                                <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('action')}}</label>
                            @endif
                        </div>
                            <div class="form-group @if($errors->has('icon')) has-error   @endif">
                                <label for="exampleInputEmail1">图标</label>
                                {!! Form::text('icon',old('action'),array('class'=>'form-control','placeholder'=>'请填写图标,如:icon-edit'))!!}
                                @if($errors->has('action'))
                                    <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('icon')}}</label>
                                @endif
                            </div>
                            <div class="form-group @if($errors->has('is_show')) has-error   @endif">
                                <label for="exampleInputEmail1">是否在菜单显示</label>
                                {!! Form::select('is_show',['YES'=>'显示','NO'=>'不显示'],old('is_show'),array('class'=>'form-control','placeholder'=>'是否在菜单显示,'))!!}
                                @if($errors->has('action'))
                                    <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('is_show')}}</label>
                                @endif
                            </div>
                        <div class="form-group">
                            <label for="exampleInputPassword1">描述</label>
                            {!! Form::textarea('description',old('description'),array('class'=>'form-control','placeholder'=>'请填写描述','rows'=>3))!!}
                        </div>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                {!! Form::close()  !!}
            </div>
            <!-- /.box -->
        </div>
    </div>



</section>
<!-- /.content -->
@endsection